package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;
import com.njuse.jvmfinal.runtimestructure.Jthread;

public class ARETURN extends Instruction {
	
	public  void readindex(ByteBuffer reader) {
		//no need to read
	}
	
	public  void execute(Jframe frame) {
		Jthread thread=frame.getMythread();
		Object temp=frame.getManagestack()[frame.getStacktop()-1];
		thread.pop();
		Jframe newframe=thread.getFrames().get(thread.getFrames().size()-1);
		Object[] stack=newframe.getManagestack();
		int top=newframe.getStacktop();
		stack[top]=temp;
		newframe.setManagestack(stack);
		newframe.setStacktop(top+1);
	}
}
